package com.xhwl.centiotdata.pojo.enums.vehicle;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum VehicleSyncEnum {

    NOTHING_SYNC(-1, "nothingSync"),
    NANTOU_SYNC(26, "nanTouSync");

    private static final Map<Integer, VehicleSyncEnum> map;
    static {
        map = new HashMap<>();
        for (VehicleSyncEnum vehicleSyncEnum : VehicleSyncEnum.values()) {
            map.put(vehicleSyncEnum.getProductId(), vehicleSyncEnum);
        }
    }

    private Integer productId;

    private String syncServiceName;

    public static VehicleSyncEnum toVehicleSyncEnum(Integer productId) {
        return Optional.ofNullable(map.get(productId)).orElse(NOTHING_SYNC);
    }

}
